#ifndef IOMANAGER_H_
#define IOMANAGER_H_

/*! \brief IOManager: A Class to manage audio I/O using OpenAL
\ingroup devDoc
 
	This class is use to manage User IO.
	This class implement ISoundIn and ISoundOut interface.
	

	This Class use windows.h and not IThread or Imutex : FIX IT !

\sa ISoundIn/ISounfOut 
*/

#include <iostream>
#include <vector>

#include <al/al.h>
#include <al/alc.h>

#include <windows.h>

#ifndef NULL
#define NULL 0
#endif /* NULL */

typedef void (*TBack)(void*);

class IOManager
{
public:
	//! IOManager constructor.
	/*!
	IOManager constructor.
	*/
	IOManager(void);
	//! IOManager destructor.
	/*!
	IOManager destructor.
	*/
	~IOManager(void);
	//! IOManager copy constructor.
	/*!
	IOManager copy constructor.
	*/
	IOManager(const IOManager&);
	//! IOManager assign constructor.
	/*!
	IOManager assign constructor.
	*/
	IOManager& operator=(const IOManager&);
	
	
	//! detectDevice
	/*!
		IAquisition implementation.
		\return A list of device name terminated by NULL. If devices can't be list NULL is return. If there is no device on machine -1 is return.
	*/
	char **detectDevice(void);


	//! selectOutDevice
	/*!
	ILecteur implementation.
	Select a device 
	\param Name of a device
	*/
	void selectOutDevice(char *);
	//! selectOutDevice
	/*!
	ILecteur implementation.
	Select a device 
	\param id of a device (use detectDevise array index of string)
	*/
	void selectOutDevice(int);
	//! autoselectOutDevice
	/*!
	ILecteur
	Select default device
	*/
	void autoselectOutDevice(void);

	//! selectInDevice
	/*!
	IAquisition implementation.
	Select a device 
	\param Name of a device
	*/
	void selectInDevice(char *);
	//! selectOutDevice
	/*!
	IAquisition implementation.
	Select a device 
	\param id of a device (use detectDevise array index of string)
	*/
	void selectInDevice(int);
	//! autoselectOutDevice
	/*!
	Select default IN device
	*/
	void autoselectInDevice(void);


	// ! startIn
	/*
	Start recording (audio IN)
	*/
	void startIn(void);
	// ! stopIn
	/*
	Stop recording (audio IN)
	*/
	void stopIn(void);
	// ! runIn
	/*
	Inside use only
	*/
	void runIn(void);
private:
	char		*_deviceList;
	char		**_deviceTable;
	ALCdevice	*_currentDevice;
	ALCdevice	*_currentInDevice;
	bool		_inRun;
};


#endif /* IOMANAGER_H_ */